module.exports = app => {
   const {STRING, INTEGER, DATE} = app.Sequelize;

   const User = app.model.define("user", {
      login: STRING,
      id: {
         type: INTEGER,
         primaryKey: true,
         autoIncrement: true
      },
      name: STRING(30),
      password: STRING(32),
      age: INTEGER,
      last_sign_in_at: DATE,
      created_at: DATE,
      updated_at: DATE
   });

   User.associate = function() {
      app.model.User.hasMany(app.model.Blog, {
         as: 'blogs',
      });
      app.model.User.hasMany(app.model.Catalog, {
         as: 'catalogs',
      });
      app.model.User.hasMany(app.model.Comment, {
         as: 'comments',
      });
      app.model.User.belongsTo(app.model.Authority);
   };


   return User;
};

